<cfsetting enablecfoutputonly="Yes">
<!---
	place.cfm
--->

<cfset place=structNew()>
<cfloop list="lat,lng,street,title,city,region,country,phone" index="colName">
	<cfif structKeyExists(URL, colName)>
		<cfset place[colName]=trim(URL[colName])>
	<cfelse>
		<cfset place[colName]="">
	</cfif>
</cfloop>

<cfmodule template="_head.cfm" pageTitle="Place">

<cfoutput>
<style type="text/css">
html, body {
	background-color: white;
	color: black;
	font-family: Calibri, Tahoma, Verdana, Arial, 'Bitstream Vera Sans', 'Vera Sans', Helvetica, sans-serif, sans;
	padding: 0;
	margin: 0;
}
p {
	margin: 0 0 0.5em 0;
}
.err {
	color: maroon;
	background-color: yellow;
	padding: 1em;
	text-align: center;
}
h1 {
	font-size: 115%;
	color: ##224488;
	margin: 0 0 0.25em 0;
	padding: 0 0 0 0;
	border-bottom: 1px solid ##3366cc;
	font-weight: bold;
}
h2 {
	font-size: 100%;
	font-weight: bold;
	color: ##666666;
	margin: 0 0 0 0;
	padding: 0 0 0 0;
	border-top: 1px solid ##dddddd;
	background-color: ##f8f8f8;
	padding-left: 0.25em;
}
.tel { float: right; }
.info {
	border-top: 1px solid ##eeeeee;
	border-bottom: 1px solid ##eeeeee;
	background-color: ##f8f8f8;
	color: ##4488ff;
	padding: 0.5em;
	text-align: center;
}
.adr { margin-bottom: 0.25em; }
td {
	padding: 0.125em 0.25em;
}
.selected { color: ##333333; background-color: ##dddddd; }
.yes .selected { color: ##006600; background-color: ##ddffdd; }
.no .selected { color: ##660000; background-color: ##ffdddd; }
span.yes { color: ##006600; }
span.no { color: ##660000; }
span.unsure { color: ##999999; }
form {
	margin: 0 0 0 0;
	padding: 0 0 0 0;
}
.radio input { float: left; }
.radio label { display: block; }
.ratingcounts td { color: ##cccccc; }
.rating-wrap {
	position: relative;
	width: 75px;
	height: 14px;
	background: url(stars75-back.png) top left;
}
.rating, .rating-wrap div {
	position: absolute;
	top: 0;
	left: 0;
	height: 14px;
	overflow: hidden;
}
.rating {
	width: 75px;
	display: block;
	border: none;
	text-decoration: none;
	text-align: left;
}
.rating-wrap div {
	width: 0px;
	background: url(stars75-front.png) top left;
}
</style>
<script language="JavaScript" type="text/javascript">
// <![CDATA[
function featureClick(a) {
	var id = a.id;
	var pair = id.split('-');
	var feat = pair[0];
	var val = pair[1];
	resetFeature(feat);
	addClass(a, 'selected');
	addClass(document.getElementById(a.id + '-label'), 'selected');
	return false;
} // featureClick
function resetFeature(f) {
	var opts = ['unsure','no','yes'];
	var j = ['','-label'];
	for(var k = 0; k < j.length; k++) { // >
		for(var i = 0; i < opts.length; i++) { // >
			var l = document.getElementById(f + '-' + opts[i] + j[k]);
			if(l != null) removeClass(l, 'selected');
		} // for i
	} // for k
} // resetFeature
function removeClass(element, className) {
    var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
    element.className = element.className.replace(regexp, "$2");
}
function addClass(element, className) {
    if (!hasClass(element, className)) {
        if (element.className) element.className += " " + className;
        else element.className = className;
    }
}
function hasClass(element, className) {
    var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
    return regexp.test(element.className);
}
var lastRatings = {};
var noMove = {};
function moveRating(e,a) {
	var t = a.id.split('-')[1];
	var id = t + 'rating';
	if(noMove[id] == null) {
		var ev = e || window.event;
		var x = ev.layerX || ev.offsetX || 0;
		lastRatings[id] = x;
		a.parentNode.childNodes[0].style.width = [ x, 'px' ].join('');
		var ri = Math.floor(x / 15);
		var rf = String(((x / 15) - ri) * 10).substring(0,1);
		document.getElementById("rating-" + t).innerHTML = " &mdash; " + ri + "." + rf;
	}
	return false;
} // moveRating
function resetRating(a) {
	var t = a.id.split('-')[1];
	var id = t + 'rating';
	if(noMove[id] == null) {
		var x = (document.forms['vote'].elements[id].value || 0);
		if(!('' + x).match(/^[0-9]([.][0-9]+)?$/)) x = 0;
		x *= 15;
		lastRatings[id] = x;
		a.parentNode.childNodes[0].style.width = [ x, 'px' ].join('');
		var ri = Math.floor(x / 15);
		var rf = String(((x / 15) - ri) * 10).substring(0,1);
		document.getElementById("rating-" + t).innerHTML = " &mdash; " + ri + "." + rf;
	}
	return false;
} // resetRating
function fixRating(a) {
	var t = a.id.split('-')[1];
	var id = t + 'rating';
	if(noMove[id] == null) {
		var x = lastRatings[id];
		if(x == null) x = 0;
		document.forms['vote'].elements[id].value = x / 15.0;
		a.parentNode.childNodes[0].style.width = [ x, 'px' ].join('');
		var ri = Math.floor(x / 15);
		var rf = String(((x / 15) - ri) * 10).substring(0,1);
		document.getElementById("rating-" + t).innerHTML = " &mdash; " + ri + "." + rf;
		noMove[id] = 1;
		setTimeout(function(){ noMove[id] = null; },5000);
	}
	return false;
} // fixRating
// ]]>
</script>
</head>
<body>
</cfoutput>

<cftry>
	<cfif not (isNumeric(place.lat) and isNumeric(place.lng) and (len(place.title) gt 0))><cfthrow message="Your browser seems to be sending us garbage.  Please reload the page."></cfif>
	<cfoutput>
<h1 class="label">#HTMLEditFormat(place.title)#</h1>
<!---
<div class="tel">#HTMLEditFormat(place.phone)#</div>
<div class="adr">
<div class="street-address">#HTMLEditFormat(place.street)#</div>
<div class="city-state-country">
	<span class="locality">#HTMLEditFormat(place.city)#</span>, <span class="region">#HTMLEditFormat(place.region)#</span> <span class="country-name">#HTMLEditFormat(place.country)#</span>
</div>
</div>
--->
<p class="info">What would you like to tell others about this place?</p>
	</cfoutput>
	<cfquery datasource="nowrists2007" name="FindVote">
	SELECT
		(CONVERT(MONEY,v.OverallRating) + 127) / 50 AS OverallRating,
		(CONVERT(MONEY,v.QuietRating) + 127) / 50 AS QuietRating,
		(CONVERT(MONEY,v.AmenitiesRating) + 127) / 50 AS AmenitiesRating,
		v.WifiFree, v.WifiPaid, v.FoodDrinks, v.FoodSolid, v.Outlets, v.OpenUntil, v.Days, v.Comment
	FROM nws_places AS p
	  INNER JOIN nws_place_votes AS v ON (p.id = v.placeId) AND (v.ip = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#CGI.REMOTE_ADDR#">)
	WHERE (p.lat = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Int(place.lat*1000000)#">)
	  AND (p.lng = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Int(place.lng*1000000)#">)
	  AND (p.title = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Left(place.title,64)#">)
	</cfquery>
	<cfoutput>
<form action="vote.cfm" method="post" target="_self" name="vote">
<cfloop collection="#place#" item="colName"><input type="hidden" name="#lCase(colName)#" value="#HTMLEditFormat(place[colName])#" id="#lCase(colName)#"/>
</cfloop>
<input type="hidden" name="overallrating" value="#HTMLEditFormat(FindVote.OverallRating)#" id="overallrating"/>
<input type="hidden" name="quietrating" value="#HTMLEditFormat(FindVote.QuietRating)#" id="quietrating"/>
<input type="hidden" name="amenitiesrating" value="#HTMLEditFormat(FindVote.AmenitiesRating)#" id="amenitiesrating"/>
<h2>Ratings</h2>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr align="center">
	<td width="33%">Overall<span id="rating-overall"></span></td>
	<td width="34%">Tranquility<span id="rating-quiet"></span></td>
	<td width="33%">Amenities<span id="rating-amenities"></span></td>
</tr>
<tr align="center">
	<td width="33%" nowrap="nowrap"><div class="rating-wrap"><div>&nbsp;</div><a href="##" class="rating" id="rate-overall" onmousemove="moveRating(event,this)" onmouseout="resetRating(this)" onclick="return(fixRating(this))">&nbsp;</a></div></td>
	<td width="34%" nowrap="nowrap"><div class="rating-wrap"><div>&nbsp;</div><a href="##" class="rating" id="rate-quiet" onmousemove="moveRating(event,this)" onmouseout="resetRating(this)" onclick="return(fixRating(this))">&nbsp;</a></div></td>
	<td width="33%" nowrap="nowrap"><div class="rating-wrap"><div>&nbsp;</div><a href="##" class="rating" id="rate-amenities" onmousemove="moveRating(event,this)" onmouseout="resetRating(this)" onclick="return(fixRating(this))">&nbsp;</a></div></td>
</tr>
</table>
<h2>Amenities</h2>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<cfloop list="Beverages:fooddrinks,Solid Food:foodsolid,Free Wifi:wififree,Paid WiFi:wifipaid,Power Outlets:outlets" index="pair">
	<cfset key=listRest(pair,":")>
<tr>
	<td class="feature" nowrap="nowrap" width="1%">#listFirst(pair,":")#:</td>
	<td width="39%" class="radio unsure"><input type="radio" name="#key#" value="unsure" id="#key#-unsure" onclick="featureClick(this)"<cfif (FindVote.RecordCount gt 0) and (FindVote[key][1] eq "")> class="selected" checked="checked"</cfif>/><label for="#key#-unsure" id="#key#-unsure-label"<cfif (FindVote.RecordCount gt 0) and (FindVote[key][1] eq "")> class="selected"</cfif>>Not Sure</label></td>
	<td width="30%" class="radio no"><input type="radio" name="#key#" value="no" id="#key#-no" onclick="featureClick(this)"<cfif (FindVote.RecordCount gt 0) and (FindVote[key][1] eq 0)> class="selected" checked="checked"</cfif>/><label for="#key#-no" id="#key#-no-label"<cfif (FindVote.RecordCount gt 0) and (FindVote[key][1] eq 0)> class="selected"</cfif>>No</label></td>
	<td width="30%" class="radio yes"><input type="radio" name="#key#" value="yes" id="#key#-yes" onclick="featureClick(this)"<cfif (FindVote.RecordCount gt 0) and (FindVote[key][1] eq 1)> class="selected" checked="checked"</cfif>/><label for="#key#-yes" id="#key#-yes-label"<cfif (FindVote.RecordCount gt 0) and (FindVote[key][1] eq 1)> class="selected"</cfif>>Yes</label></td>
</tr>
</cfloop>
<tr>
	<td colspan="4" align="center"><input type="submit" value="Save &rarr;"/></td>
</tr>
</table>
</form>
	</cfoutput>
<cfcatch>
	<cfoutput><p class="err">#CFCatch.Message#</p></cfoutput>
</cfcatch>
</cftry>

<cfmodule template="_foot.cfm">

<cfsetting enablecfoutputonly="No">